home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / disk utilities / dirutil / dopus / opus5utils / arexx / playmod_dt.dopus5 < prev    next >
Encoding:
Text File  |  1997-11-21  |  5.0 KB  |  145 lines

  1. /* Mod-Player for Directory Opus 5.
  2.    By Leo Davidson ("Nudel", P0T-NOoDLE/Gods'Gift Utilities)
  3.  
  4. $VER: PlayMod_DT.dopus5 1.2 (18.8.95)
  5.  
  6.    This version is for use with DeliTracker by Peter Kunath & Frank Riffel
  7.    (Delirium Softdesign), but should be easy to adapt to any other player
  8.    with an ARexx port, such as MultiPlayer, EagleTracker, DMP, etc.
  9.    (In fact, a MultiPlayer version should come with this script!).
  10.  
  11.    If you include the path of a module on the command line, using {f}, only
  12.    this mod will be played. If you omit the {f}, the program will play each
  13.    selected file in the first SOURCE lister, giving you a requester to go to
  14.    the next file or stop playing.
  15.  
  16.    If the player's ARexx port is not found, the program will be run for
  17.    you (you should edit the path below). This means the script may fail if
  18.    you disable the player's ARexx port, or give an incorrect command line
  19.    to it.
  20.    If the player's ARexx port takes over a minute to appear, an error
  21.    requester will appear on the DOpus screen and the script will quit.
  22.    REMEMBER to add the "RUN" command to the player command line if it does
  23.    not automatically detach from the shell (DeliTracker doesn't)!
  24.  
  25.    If the player was running to start with, or the user selects
  26.    "Leave Playing", the module will continue playing when the script finishes.
  27.    Otherwise, the player will be quit.
  28.  
  29. Call as:
  30. ------------------------------------------------------------------------------
  31. ARexx    DOpus5:ARexx/PlayMod_DT.dopus5 {Qp} [{f}]
  32. ------------------------------------------------------------------------------
  33. Turn off all switches.
  34. "[]" means this part is optional.
  35.  
  36.    v1.00 -> v1.01 - Now uses stem variables to get the lister handle.
  37.                     Some minor tidying up.
  38.                     Now checks to make sure the DOPUS.x port exists.
  39.     v1.01 -> v1.2 - Now uses Show() instead of ShowList(). (Thanks Stoebi)
  40.                     Style Guide compliant version numbering and $VER string.
  41.  
  42. */
  43. /*- Path to DeliTracker command --------------------------------------------*/
  44. DeliTracker = "RUN >NIL: <NIL: DH0:Tools/Music/DeliTracker2"
  45. /*--------------------------------------------------------------------------*/
  46. options results
  47. options failat 99
  48. signal on syntax;signal on ioerr        /* Error trapping */
  49. parse arg DOpusPort FilePath
  50. DOpusPort = Strip(DOpusPort,"B",'" ')
  51. FilePath = Strip(FilePath,"B",'" ')
  52.  
  53. If DOpusPort="" THEN Do
  54.     Say "Not correctly called from Directory Opus 5!"
  55.     Say "Load this ARexx script into an editor for more info."
  56.     EXIT
  57.     END
  58. If ~Show("P",DOpusPort) Then Do
  59.     Say DOpusPort "is not a valid port."
  60.     EXIT
  61.     End
  62. Address value DOpusPort
  63.  
  64. Quit_After = "NO"
  65. If ~Show("P","DELITRACKER") Then Do
  66.     Address Command DeliTracker
  67.     Quit_After = "YES"
  68.     TickTick = Time(M)
  69.     Do While ~Show("P","DELITRACKER")
  70.         IF Time(M) - TickTick > 0 Then Do
  71.             dopus request '"Error loading DeliTracker!'||X2C(0A)||'Check its command-line in the ARexx script itself." OK'
  72.             EXIT
  73.             END
  74.         END
  75.     END
  76.  
  77. /* If file-path was specified on command line, just play that mod, else
  78.    go through all the selected ones. */
  79.  
  80. If FilePath = "" Then Do
  81.  
  82.     lister query source stem source_handle.
  83.     IF source_handle.count = 0 | source_handle.count = "SOURCE_HANDLE.COUNT" Then Do
  84.         dopus request '"You must have a SOURCE lister!" OK'
  85.         EXIT
  86.         End
  87.     lister set source_handle.0 busy 1
  88.  
  89.     lister query source_handle.0 numselentries    /* Get info about selected */
  90.     Lister_NumSelEnt = RESULT            /* entries & path to them */
  91.     lister query source_handle.0 path
  92.     Lister_Path = Strip(RESULT,"B",'"')
  93.  
  94.     Do i=1 to Lister_NumSelEnt
  95.         lister query source_handle.0 firstsel
  96.         Temp_Name = Strip(RESULT,"B",'"')
  97.         lister select source_handle.0 Temp_Name 0
  98.         Temp_Path = Lister_Path||Temp_Name
  99.         Address DELITRACKER PlayMod Temp_Path
  100.  
  101.         If Lister_NumSelEnt - i > 0 Then Do
  102.             If Quit_After = "YES" Then
  103.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':'||X2C(0A)||Temp_Name||'" Next|Leave Playing|Stop'
  104.             Else
  105.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':'||X2C(0A)||Temp_Name||'" Next|Leave Playing'
  106.             IF RC = "0" THEN BreakIt = "YES"
  107.             IF RC = "2" THEN Do
  108.                 BreakIt = "YES"
  109.                 Quit_After = "NO"
  110.                 END
  111.             End
  112.  
  113.         Else Do
  114.             If Quit_After = "YES" Then
  115.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':'||X2C(0A)||Temp_Name||'" Leave Playing|Stop'
  116.             Else
  117.                 dopus request '"Playing module ' i ' of ' Lister_NumSelEnt ':'||X2C(0A)||Temp_Name||'" Leave Playing'
  118.             IF RC = "1" Then Quit_After = "NO"
  119.             End
  120.  
  121.         IF BreakIt = "YES" THEN BREAK
  122.         END
  123.     End
  124.  
  125. ELSE Do
  126.     Address DELITRACKER PlayMod FilePath
  127.     If Quit_After = "YES" Then
  128.         dopus request '"Playing module:'||X2C(0A)||FilePath'" Leave Playing|Stop'
  129.     Else
  130.         dopus request '"Playing module:'||X2C(0A)||FilePath'" Leave Playing'
  131.     IF RC ~= "0" THEN Quit_After = "NO"
  132.     End
  133.  
  134. /*-- Restore the Lister for normal use --------------------------------------*/
  135. syntax:;ioerr:                /* In case of error, jump here */
  136. END_PART_2:
  137. If FilePath = "" Then Do
  138.     lister refresh source_handle.0
  139.     lister set source_handle.0 busy 0
  140.     END
  141. END_PART:
  142. If Quit_After = "YES" Then Address DELITRACKER QUIT
  143.  
  144. EXIT
  145.